<?php

namespace App\Http\Controllers\Teacher;

use App\Http\Controllers\Controller;

use Illuminate\Foundation\Auth\User;
use Illuminate\Http\Request;


class LoginController extends Controller
{

    //登录视图u
    /**
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index()
    {
       return view('teacher.login.login');
    }
    public function login(Request $request){
      /*  i\Auth::guard($guard)->guest()) {*/
        $post=$this->validate($request,[
            'username'=>'required',
            'password'=>'required',
        ]);
        $bool=\Auth::guard('teacher')->attempt($post);

        if ($bool){
            return redirect(route('teacher.index'));
        }
        return redirect(route('teacher.login'))->with(['error'=>'密码错误']);
    }
}
